<div class="content">
	<div class="detail-top">
		<?php 
			$area	=	$location->area;
			//print_r($result);
		?>
		<?php foreach($result as $k => $v):?>
		<table class="tbl-list">
			<tr>
				<td colspan="2">Xổ số <?php echo $location->name;?> ngày: <?php echo date('d/m/y',strtotime($v->date));?></td>
			</tr>
			<tr>
				<th class="first">ĐB:</th>
				<th class="last">
							<?php $str = '';?>
                            <?php $n = 5;?>
                            <?php if($area == 'MB'):?>
                            <?php $n = 5;?>
                            <?php elseif($area == 'MT'):?>
                            <?php $n = 5;?>
                            <?php else:?>
                            <?php $n = 6;?>
                            <?php endif;?>
                            <?php for($i =0; $i < $n; $i++):?>
                            <?php
                                $s = substr($v->a0,$i,1);
                                
                                if($i==$from || $i==$to)
                                {
                                    $str.='<strong class="red" style="font-size: 20px;">'.$s.'</strong>';
                                }   
                                else
                                {
                                    $str.=$s;
                                }
                            ?>
                            <?php endfor;?>
                            <?php echo $str;?>
				</th>
			</tr>
			<tr>
				<td>G1:</td>
				<td>
					<?php $str = '';?>
                            <?php $n = 0;$m = 0;?>
                            <?php if($area == 'MB'):?>
                            <?php $n = 5;$m = 10;?>
                            <?php elseif($area == 'MT'):?>
                            <?php $n = 5;$m = 10;?>
                            <?php else:?>
                            <?php $n = 6; $m = 11;?>
                            <?php endif;?>
                            <?php for($i = $n; $i < $m; $i++):?>
                            <?php
                                $s = substr($v->a1,($i-$n),1);
                                
                                if($i==$from || $i==$to)
                                {
                                    $str.='<strong class="red" style="font-size: 20px;">'.$s.'</strong>';
                                }   
                                else
                                {
                                    $str.=$s;
                                }
                            ?>
                            <?php endfor;?>
                            <?php echo $str;?>
				</td>
			</tr>
			<tr>
				<td>G2:</td>
				<td>
					<?php $n = 0;$m = 0;?>
                            <?php if($area == 'MB'):?>
                            <?php $n = 10;$m = 20;?>
                            <?php elseif($area == 'MT'):?>
                            <?php $n = 10;$m = 15;?>
                            <?php else:?>
                            <?php $n = 11; $m = 16;?>
                            <?php endif;?>
                        <?php $str = '';?>
                            <?php for($i = $n; $i < $m; $i++):?>
                            <?php
                                $s = substr(str_replace('-','',$v->a2),($i-$n),1);
                                
                                if($area == 'MB'){
                                    if($i==15)
                                    {
                                        $str.='<span>-</span>';
                                    }
                                }
                                
                                
                                if($i==$from || $i==$to)
                                {
                                    $str.='<strong class="red" style="font-size: 20px;">'.$s.'</strong>';
                                }  
                                else
                                {
                                    $str.=$s;
                                }
                            ?>
                            <?php endfor;?>
                            <?php echo $str;?>
				</td>
			</tr>
			<tr>
				<td>G3:</td>
				<td>
					<?php $n = 0;$m = 0;?>
                            <?php if($area == 'MB'):?>
                            <?php $n = 20;$m = 50;?>
                            <?php elseif($area == 'MT'):?>
                            <?php $n = 15;$m = 25;?>
                            <?php else:?>
                            <?php $n = 16; $m = 26;?>
                            <?php endif;?>
                        <?php $str = '';?>
                            <?php for($i = $n; $i < $m; $i++):?>
                            <?php
                                $s = substr(str_replace('-','',$v->a3),($i-$n),1);
                                
                                if($area == 'MB')
                                {
                                    if($i==25 || $i == 30 || $i == 40 || $i == 45)
                                    {
                                        $str.='<span>-</span>';
                                    }
                                }
                                elseif($area == 'MT')
                                {
                                    if($i == 20)
                                    {
                                        $str.='<span>-</span>';
                                    }
                                }
                                else
                                {
                                    if($i == 21)
                                    {
                                        $str.='<span>-</span>';
                                    }
                                }
                                
                                if($i==35){$str.='<br />';}
                                
                                if($i==$from || $i==$to)
                                {
                                    $str.='<strong class="red" style="font-size: 20px;">'.$s.'</strong>';
                                }  
                                else
                                {
                                    $str.=$s;
                                }
                                
                                
                            ?>
                            <?php endfor;?>
                            <?php echo $str;?>
				</td>
			</tr>
			<tr>
				<td>G4:</td>
				<td>
					<?php $n = 0;$m = 0;?>
                            <?php if($area == 'MB'):?>
                            <?php $n = 50;$m = 66;?>
                            <?php elseif($area == 'MT'):?>
                            <?php $n = 25;$m = 60;?>
                            <?php else:?>
                            <?php $n = 26; $m = 61;?>
                            <?php endif;?>
                        <?php $str = '';?>
                            <?php for($i = $n; $i < $m; $i++):?>
                            <?php
                                $s = substr(str_replace('-','',$v->a4),($i-$n),1);
                                
                                if($area == 'MB')
                                {
                                    if($i==54 || $i == 58 || $i == 62)
                                    {
                                        $str.='<span>-</span>';
                                    }
                                }
                                elseif($area == 'MT')
                                {
                                    if($i == 30 || $i == 35 || $i == 40 || $i == 50 || $i == 55)
                                    {
                                        $str.='<span>-</span>';
                                    }
                                	if($i == 45)
                                    {
                                    	
                                    	$str.='<br />';
                                    }
                                }
                                else
                                {
                                    if($i == 31 || $i == 36 || $i == 41 || $i == 51 || $i == 56)
                                    {
                                        $str.='<span>-</span>';
                                    }
                                    
                                    if($i == 46)
                                    {
                                    	
                                    	$str.='<br />';
                                    }
                                }
                                
                                if($i==$from || $i==$to)
                                {
                                    $str.='<strong class="red" style="font-size: 20px;">'.$s.'</strong>';
                                } 
                                else
                                {
                                    $str.=$s;
                                }
                            ?>
                            <?php endfor;?>
                            <?php echo $str;?>
				</td>
			</tr>
			<tr>
				<td>G5:</td>
				<td>
					<?php $n = 0;$m = 0;?>
                            <?php if($area == 'MB'):?>
                            <?php $n = 66;$m = 90;?>
                            <?php elseif($area == 'MT'):?>
                            <?php $n = 60;$m = 64;?>
                            <?php else:?>
                            <?php $n = 61; $m = 65;?>
                            <?php endif;?>
                        <?php $str = '';?>
                            <?php for($i = $n; $i < $m; $i++):?>
                            <?php
                                $s = substr(str_replace('-','',$v->a5),($i-$n),1);
                                
                                if($area == 'MB')
                                {
                                    if($i==86 || $i == 70 || $i == 74 || $i == 82)
                                    {
                                        $str.='<span>-</span>';
                                    }
                                    if($i==78){$str.='<br />';}
                                }
                                
                                if($i==$from || $i==$to)
                                {
                                    $str.='<strong class="red" style="font-size: 20px;">'.$s.'</strong>';
                                }   
                                
                                else
                                {
                                    $str.=$s;
                                }
                                
                            ?>
                            <?php endfor;?>
                            <?php echo $str;?>
				</td>
			</tr>
			<tr>
				<td>G6</td>
				<td>
					<?php $n = 0;$m = 0;?>
                            <?php if($area == 'MB'):?>
                            <?php $n = 90;$m = 99;?>
                            <?php elseif($area == 'MT'):?>
                            <?php $n = 64;$m = 76;?>
                            <?php else:?>
                            <?php $n = 65; $m = 77;?>
                            <?php endif;?>
                        <?php $str = '';?>
                            <?php for($i = $n; $i < $m; $i++):?>
                            <?php
                                $s = substr(str_replace('-','',$v->a6),($i-$n),1);
                                
                                if($area == 'MB')
                                {
                                    if($i==93 || $i == 96)
                                    {
                                        $str.='<span>-</span>';
                                    }
                                }
                                elseif($area == 'MT')
                                {
                                    if($i == 68 || $i == 72 )
                                    {
                                        $str.='<span>-</span>';
                                    }
                                }
                                else
                                {
                                    if($i == 69 || $i == 73 )
                                    {
                                        $str.='<span>-</span>';
                                    }
                                }
                                
                                if($i==$from || $i==$to)
                                {
                                    $str.='<strong class="red" style="font-size: 20px;">'.$s.'</strong>';
                                } 
                                else
                                {
                                    $str.=$s;
                                }
                            ?>
                            <?php endfor;?>
                            <?php echo $str;?>
				</td>
			</tr>
			<tr>
				<td>G7</td>
				<td>
					<?php $n = 0;$m = 0;?>
                            <?php if($area == 'MB'):?>
                            <?php $n = 99;$m = 107;?>
                            <?php elseif($area == 'MT'):?>
                            <?php $n = 76;$m = 79;?>
                            <?php else:?>
                            <?php $n = 77; $m = 80;?>
                            <?php endif;?>
                        <?php $str = '';?>
                            <?php for($i = $n; $i < $m; $i++):?>
                            <?php
                                $s = substr(str_replace('-','',$v->a7),($i-$n),1);
                                
                                if($i==101 || $i == 103 || $i == 105)
                                {
                                    $str.='<span>-</span>';
                                }
                                
                                if($i==$from || $i==$to)
                                {
                                    $str.='<strong class="red" style="font-size: 20px;">'.$s.'</strong>';
                                }  
                                else
                                {
                                    $str.=$s;
                                }
                            ?>
                            <?php endfor;?>
                            <?php echo $str;?>
				</td>
			</tr>
			<?php if($area == 'MN' || $area == 'MT'):?>
			<tr>
				<td>G8</td>
				<td>
					<?php $n = 0;$m = 0;?>
                            <?php if($area == 'MT'):?>
                            <?php $n = 79;$m = 81;?>
                            <?php else:?>
                            <?php $n = 80; $m = 82;?>
                            <?php endif;?>
                        <?php $str = '';?>
                            <?php for($i = $n; $i < $m; $i++):?>
                            <?php
                                $s = substr(str_replace('-','',$v->a8),($i-$n),1);
                                
                                if($i==101 || $i == 103 || $i == 105)
                                {
                                    $str.='<span>-</span>';
                                }
                                
                                if($i==$from || $i==$to)
                                {
                                    $str.='<strong class="red" style="font-size: 20px;">'.$s.'</strong>';
                                }  
                                else
                                {
                                    $str.=$s;
                                }
                            ?>
                            <?php endfor;?>
                            <?php echo $str;?>
				</td>
			</tr>
			<?php endif;?>
		</table>
		<table class="tbl-list">
			<tr>
				<th class="first">Đầu</th>
				<th class="last">Đuôi</th>
			</tr>
					<?php 
					$extension = json_decode($v->extension);
					if(isset($result[$k+1]->data))
					{
						$string	=	$result[$k+1]->data;
						$num_pre	=	substr($string,$from,1).substr($string,$to,1);
					}
					?>
					<?php foreach($extension as $kv => $vv):?>
					<tr>
						<td><?php echo $kv;?></td>
						<td>
						<?php 
							$arr = explode(',',$vv);
							foreach($arr as $kvv => $vvv)
							{
								if($num_pre == $kv.$vvv || $num_pre == strrev($kv.$vvv))
								{
									echo '<strong class="red" style="font-size: 20px;">'.$vvv.'</strong>';
								}
								else
								{
									echo '<span>'.$vvv.'</span>';
								}
								
							}
						?>
						</td>
					</tr>
					<?php endforeach;?>
		</table>
		<?php endforeach;?>
		<div class="share-ico">
			<?php $this->load->view('client/layout/shared');?>
		</div>
		<div class="box-detail"><a href="#" class="box-css3">SOI CẦU LOTO <img src="<?php echo img_link('new.png');?>" width="60" height="29" /></a></div>
		<div class="box-detail"><span class="box-css3">THỐNG KÊ</span></div>
	</div>
	<ul class="link1">
		<li><a href="#">Thong ke 10 ngay</a></li>
		<li><a href="#">Thong ke 20 ngay</a></li>
		<li><a href="#">Thong ke 30 ngay</a></li>
		<li><a href="#">Tra cứu kết quả</a></li>
	</ul>
</div>